package com.jay.lang.management.clazz;

import java.lang.management.ManagementFactory;
import java.lang.management.ThreadInfo;
import java.lang.management.ThreadMXBean;

public class ThreadInfoCls {
	public static void main(String[] args) {

		ThreadMXBean mxbean = ManagementFactory.getThreadMXBean();

		long[] ids = mxbean.getAllThreadIds();
		ThreadInfo[] tis = mxbean.getThreadInfo(ids);
		for (ThreadInfo ti : tis) {
			System.out.println("---------------");
			System.out.println(ti);
			System.out.println(ti.getBlockedCount());
			System.out.println(ti.getBlockedTime());
			System.out.println(ti.getLockName());
			System.out.println(ti.getLockOwnerId());
			System.out.println(ti.getLockOwnerName());
			System.out.println(ti.getThreadId());
			System.out.println(ti.getThreadName());
			System.out.println(ti.getWaitedCount());
			System.out.println(ti.getWaitedTime());
			System.out.println(ti.isInNative());
			System.out.println(ti.isSuspended());
			System.out.println(ti.getThreadState());
		}

		tis = mxbean.dumpAllThreads(true, true);
		for (ThreadInfo ti : tis) {
			System.out.println("---------------");
			System.out.println(ti);
		}
	}
}
